// src/composables/useApi.ts
import { ref } from 'vue'
import request from '@/utils/request'

async function fetchServerData() {
  const token = localStorage.getItem('pax_token')
  const result = await request.get("pax/server_view/", {
    headers: { "Authorization": token }
  })
  return ref(result)
}

async function fetchItemData(data: any) {
  const token = localStorage.getItem('pax_token')
  const result = await request.get("pax/item_view/", {
    headers: { "Authorization": token },
    params: data
  })
  return ref(result.data)
}

async function RequestSendMail(data: any) {
  const token = localStorage.getItem('pax_token')
  const result = await request.post("pax/send_email/", data,{
    headers: { "Authorization": token }
  })
  return ref(result)
}

async function RequestGodSkill(data: any) {
  const token = localStorage.getItem('pax_token')
  const result = await request.post("pax/god_skill/", data,{
    headers: { "Authorization": token, 'Content-Type': 'multipart/form-data' }
  })
  return ref(result)
}


export { fetchServerData, fetchItemData, RequestSendMail, RequestGodSkill}